home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / apps / 136 / applic / quiklbl2.pas < prev    next >
Pascal/Delphi Source File  |  1987-05-14  |  17KB  |  435 lines

  1. PROGRAM quicklabel  ;  { By David Lindsley }
  2.  
  3.   CONST
  4.     {$I GEMCONST.PAS}
  5.  
  6.   TYPE
  7.     {$I gemtype.pas}
  8.         Txtfile = File of Text;
  9.         Adrptr = ^Adrlist;
  10.         Adrlist =
  11.            RECORD
  12.              FirstLine: Str255;
  13.              SecondLine: Str255;
  14.              ThirdLine: Str255;
  15.              FourthLine: Str255;
  16.            END;
  17.  
  18.   VAR
  19.     status : long_integer;
  20.     dialog, Info_Box, Style_box : Dialog_Ptr ;
  21.     a, b,c, d, e, f, g, res, dummy,
  22.     info_btn, print_btn, cancel_btn, size_btn,
  23.     first_item, second_item, third_item, fourth_item : integer ;
  24.     alert_str : Str255 ;
  25.     Adrfile: Txtfile;
  26.     Adrs : Adrptr;
  27.     button : Tree_Index;
  28.     flag, tall_flag, wide_flag, bold_flag, cond_flag,
  29.     italic_flag, normal_flag : Boolean;
  30.  
  31.   {$I gemsubs}
  32.  
  33. FUNCTION printout_stat : long_integer;
  34.     GEMDOS($11);
  35.  
  36. FUNCTION getrez : integer;
  37.     XBIOS( 4 );
  38.  
  39. PROCEDURE styledialog ;
  40.  
  41.     VAR
  42.       button, ok_btn, style_item, wide_btn,
  43.       tall_btn, italic_btn, bold_btn,
  44.       cond_btn, normal_btn : integer ;
  45.  
  46.     BEGIN
  47.       Style_Box := New_Dialog ( 15, 0, 0, 36, 18 ) ;
  48.       style_item := Add_DItem(Style_Box, G_Text, None, 11, 1, 15, 1, 0, $1180);
  49.       Set_DText (Style_Box, style_item, '*** STYLE ***', System_Font,
  50.                   TE_Center ) ;
  51.       wide_btn := Add_DItem(Style_Box, G_Button, Touch_Exit,
  52.                        5, 4, 11, 2, 1, $1180 );
  53.       Set_DText ( Style_Box, wide_btn, 'Wide', System_Font, TE_Center );
  54.       Obj_SetState(Style_Box, wide_btn, 0, false );
  55.       if wide_flag then
  56.           obj_SetState(Style_box, wide_btn, 4, false );
  57.  
  58.       tall_btn := Add_DItem ( Style_Box, G_Button, Touch_Exit,
  59.                        5, 7, 11, 2, 1, $1180) ;
  60.       Set_DText ( Style_Box, tall_btn, 'Tall', System_Font, TE_Center );
  61.       Obj_SetState(Style_Box, tall_btn, 0, false );
  62.       if tall_flag then
  63.           obj_SetState(Style_Box, tall_btn, 4, false );
  64.       italic_btn := Add_DItem( Style_Box, G_Button, Touch_Exit,
  65.                        20, 4, 11, 2, 1, $1180);
  66.       Set_DText ( Style_Box, italic_btn, 'Italic',System_Font, TE_Center );
  67.       Obj_SetState(Style_Box, italic_btn, 0, false );
  68.       if italic_flag then
  69.           obj_SetState(Style_Box, italic_btn, 4, false );
  70.       bold_btn := Add_DItem ( Style_Box, G_Button, Touch_Exit,
  71.                        20, 7, 11, 2, 1, $1180);
  72.       Set_DText ( Style_Box, bold_btn, 'Bold', System_Font, TE_Center );
  73.       Obj_SetState(Style_Box, bold_btn, 0, false );
  74.       if bold_flag then
  75.           obj_SetState(Style_Box, bold_btn, 4, false );
  76.       cond_btn := Add_DItem ( Style_Box, G_Button, Touch_Exit,
  77.                        20, 10, 11, 2, 1, $1180);
  78.       Set_DText ( Style_Box, cond_btn, 'Condensed',System_Font, TE_Center );
  79.       Obj_SetState(Style_Box, cond_btn, 0, false );
  80.       if cond_flag then
  81.           obj_SetState(Style_Box, cond_btn, 4, false );
  82.       normal_btn := Add_DItem( Style_Box,G_Button, Touch_Exit,
  83.                         5, 10, 11, 2, 1, $1180);
  84.       Set_DText ( Style_Box, normal_btn, 'Normal', System_Font, TE_Center );
  85.       Obj_SetState(Style_Box, normal_btn, 0, false );
  86.       if normal_flag then
  87.           obj_SetState(Style_Box, normal_btn, 4, false );
  88.       ok_btn := Add_DItem( Style_Box, G_Button, Selectable|Exit_Btn|Default,
  89.                         13, 15, 11, 2, 2, $1180 ) ;
  90.       Set_DText (Style_Box, ok_btn, 'Okay', System_Font, TE_Center ) ;
  91.       Center_Dialog ( Style_Box) ;
  92.       button := Do_Dialog ( Style_Box, 0 ) ;
  93.          while (button=wide_btn) or (button=tall_btn) or (button=normal_btn)
  94.            or (button=italic_btn) or (button=bold_btn) or (button=cond_btn)
  95.            do begin
  96.             IF button = wide_btn THEN
  97.                 BEGIN
  98.                   a := obj_state(Style_Box, wide_btn);
  99.                   if a=4 then begin
  100.                      obj_setstate(Style_box, wide_btn, 0, true );
  101.                      Rewrite(Adrfile, 'PRN:');
  102.                      Write(Adrfile, chr(27), chr(87), chr(0));
  103.                   end;
  104.                   if a <> 4 then begin
  105.                      g := obj_state(Style_Box, normal_btn);
  106.                      if g=4 then begin
  107.                        obj_setstate(Style_box, normal_btn, 0, true );
  108.                      end;
  109.                      obj_setstate(Style_box, wide_btn,4, true );
  110.                      Rewrite(Adrfile, 'PRN:');
  111.                      Write(Adrfile, chr(27), chr(87), chr(1));
  112.                   end;
  113.                 END;
  114.         IF button = tall_btn THEN
  115.                 BEGIN
  116.                   b := obj_state(Style_Box, tall_btn);
  117.                   if b=4 then begin
  118.                      obj_setstate(Style_box, tall_btn, 0, true );
  119.                      Rewrite(Adrfile, 'PRN:');
  120.                      Write(Adrfile, chr(28), chr(86), chr(0));
  121.                        { for Epson: chr(27), chr(104),chr(0) }
  122.  
  123.                   end;
  124.                   if b <> 4 then begin
  125.                      g := obj_state(Style_Box, normal_btn);
  126.                      if g=4 then begin
  127.                        obj_setstate(Style_box, normal_btn, 0, true );
  128.                      end;
  129.                      obj_setstate(Style_box, tall_btn,4, true );
  130.                      Rewrite(Adrfile, 'PRN:');
  131.                      Write(Adrfile, chr(28), chr(86), chr(1));
  132.                        { for Epson: chr(27), chr(104), chr(1))  }
  133.                   end;
  134.                 END;
  135.         IF button = italic_btn THEN
  136.                 BEGIN
  137.                   d := obj_state(Style_Box, italic_btn);
  138.                   if d=4 then begin
  139.                      obj_setstate(Style_box, italic_btn, 0, true );
  140.                      Rewrite(Adrfile, 'PRN:');
  141.                      Write(Adrfile, chr(27), chr(53));
  142.                   end;
  143.                   if d <> 4 then begin
  144.                      g := obj_state(Style_Box, normal_btn);
  145.                      if g=4 then begin
  146.                        obj_setstate(Style_box, normal_btn, 0, true );
  147.                      end;
  148.                      obj_setstate(Style_box, italic_btn,4, true );
  149.                      Rewrite(Adrfile, 'PRN:');
  150.                      Write(Adrfile, chr(27), chr(52));
  151.                   end;
  152.                 END;
  153.         IF button = bold_btn THEN
  154.                 BEGIN
  155.                   e := obj_state(Style_Box, bold_btn);
  156.                   if e=4 then begin
  157.                      obj_setstate(Style_box, bold_btn, 0, true );
  158.                       Rewrite(Adrfile, 'PRN:');
  159.                       Write(Adrfile, chr(27), chr(72));
  160.                    end;
  161.                   if e <> 4 then begin
  162.                      g := obj_state(Style_Box, normal_btn);
  163.                      if g=4 then begin
  164.                        obj_setstate(Style_box, normal_btn, 0, true );
  165.                      end;
  166.                      obj_setstate(Style_box, bold_btn,4, true );
  167.                      Rewrite(Adrfile, 'PRN:');
  168.                      Write(Adrfile, chr(27), chr(71));
  169.                   end;
  170.                 END;
  171.         IF button = cond_btn THEN
  172.                 BEGIN
  173.                   f := obj_state(Style_Box, cond_btn);
  174.                   if f=4 then begin
  175.                      obj_setstate(Style_box, cond_btn, 0, true );
  176.                      Rewrite(Adrfile, 'PRN:');
  177.                      Write(Adrfile, chr(18));
  178.                   end;
  179.                   if f <> 4 then begin
  180.                      g := obj_state(Style_Box, normal_btn);
  181.                      if g=4 then begin
  182.                        obj_setstate(Style_box, normal_btn, 0, true );
  183.                      end;
  184.                      obj_setstate(Style_box, cond_btn,4, true );
  185.                      Rewrite(Adrfile, 'PRN:');
  186.                      Write(Adrfile, chr(27), chr(15));
  187.                   end;
  188.                 END;
  189.         IF button = normal_btn THEN
  190.           BEGIN
  191.                   g := obj_state(Style_Box, normal_btn);
  192.                   if g=4 then begin
  193.                      obj_setstate(Style_box, normal_btn, 0, true );
  194.                   end;
  195.                   if g <> 4 then begin
  196.                   a := obj_state(Style_Box, wide_btn);
  197.                   b := obj_state(Style_Box, tall_btn);
  198.                   d := obj_state(Style_Box, italic_btn);
  199.                   e := obj_state(Style_Box, bold_btn);
  200.                   f := obj_state(Style_Box, cond_btn);
  201.                   if a=4 then begin
  202.                      obj_setstate(Style_box, wide_btn, 0, true );
  203.                   end;
  204.                   if b=4 then begin
  205.                      obj_setstate(Style_box, tall_btn, 0, true );
  206.                   end;
  207.                   if d=4 then begin
  208.                      obj_setstate(Style_box, italic_btn, 0, true );
  209.                   end;
  210.                   if e=4 then begin
  211.                      obj_setstate(Style_box, bold_btn, 0, true );
  212.                   end;
  213.                   if f=4 then begin
  214.                      obj_setstate(Style_box, cond_btn, 0, true );
  215.                   end;
  216.                      obj_setstate(Style_box, normal_btn,4, true );
  217.                      Rewrite(Adrfile, 'PRN:');
  218.                      Write(Adrfile, chr(27), chr(64));
  219.                   end;
  220.           END;
  221. button := Redo_Dialog (Style_Box,0);
  222. end;
  223.  if button = ok_btn then begin
  224.   a := obj_state(Style_box, wide_btn);
  225.   if a = 4 then
  226.      wide_flag := true;
  227.   if a <> 4 then
  228.      wide_flag := false;
  229.  
  230.   b := obj_state(Style_box, tall_btn);
  231.   if b = 4 then
  232.      tall_flag := true;
  233.   if b <> 4 then
  234.      tall_flag := false;
  235.  
  236.   d := obj_state(Style_box, italic_btn);
  237.   if d = 4 then
  238.      italic_flag := true;
  239.   if d <> 4 then
  240.      italic_flag := false;
  241.  
  242.   e := obj_state(Style_box, bold_btn);
  243.   if e = 4 then
  244.      bold_flag := true;
  245.   if e <> 4 then
  246.      bold_flag := false;
  247.  
  248.   f := obj_state(Style_box, cond_btn);
  249.   if f = 4 then
  250.      cond_flag := true;
  251.   if f <> 4 then
  252.      cond_flag := false;
  253.  
  254.   g := obj_state(Style_box, normal_btn);
  255.   if g = 4 then
  256.      normal_flag := true;
  257.   if g <> 4 then
  258.      normal_flag := false;
  259.   end;
  260.  
  261.   End_Dialog ( Style_Box ) ;
  262. END ;
  263.  
  264. PROCEDURE infodialog ;
  265.  
  266.     VAR
  267.       button, ok_btn, more_btn, info_item : integer ;
  268.  
  269.     BEGIN
  270.       Info_Box := New_Dialog ( 15, 0, 0, 40, 19 ) ;
  271.       Info_item := Add_DItem ( Info_Box, G_Text, None, 2, 1, 36, 1, 0, $1180) ;
  272.       Set_DText( Info_Box, Info_item, 'QUICK LABEL PROGRAM', System_Font,
  273.                   TE_Center ) ;
  274.       info_item := Add_DItem ( Info_Box, G_Text, None, 2, 3, 36, 1, 0, $1180 );
  275.       Set_DText ( Info_Box, info_item, 'by David Lindsley', Small_Font,
  276.                   TE_Center ) ;
  277.       info_item := Add_DItem ( Info_Box, G_Text, None, 2, 5, 36, 1, 0, $1180 );
  278.       Set_DText ( Info_Box, info_item, '* Use TAB or arrow keys', System_Font,
  279.                   TE_Center ) ;
  280.       info_item := Add_DItem ( Info_Box, G_Text, None, 2, 6, 36, 1, 0, $1180) ;
  281.       Set_DText ( Info_Box, info_item,'to advance to next line.',System_Font,
  282.                   TE_Center ) ;
  283.       info_item := Add_DItem ( Info_Box, G_Text, None, 2, 8, 36, 1, 0, $1180) ;
  284.       Set_DText ( Info_Box, info_item, '* Use RETURN or "PRINT" button',
  285.                    System_Font, TE_Center ) ;
  286.       info_item := Add_DItem ( Info_Box, G_Text, None, 2, 9, 36, 1, 0, $1180);
  287.       Set_DText ( Info_Box, info_item, 'to print label.',
  288.                   System_Font, TE_Center ) ;
  289.       info_item := Add_DItem ( Info_Box, G_Text, None, 2, 11, 36, 1, 0, $1180);
  290.       Set_DText ( Info_Box, info_item, '* Use ESC key to clear line.',
  291.                   System_Font, TE_Center ) ;
  292.       info_item := Add_DItem ( Info_Box, G_Text, None, 2, 14, 36, 1, 0, $1180);
  293.       Set_DText ( Info_Box, info_item, 'Portions of this program copyright',
  294.                   Small_Font, TE_Center ) ;
  295.       info_item := Add_DItem ( Info_Box, G_Text, None, 2, 15, 36, 1, 0, $1180);
  296.       Set_DText ( Info_Box, info_item,
  297.              'OSS and CCD. Used by permission',
  298.                   Small_Font, TE_Center ) ;
  299.       ok_btn := Add_DItem ( Info_Box, G_Button, Selectable|Exit_Btn|Default,
  300.                             16, 17, 8, 1, 2, $1180 ) ;
  301.       Set_DText ( Info_Box, ok_btn, 'OKAY', System_Font, TE_Center ) ;
  302.       Center_Dialog ( Info_Box) ;
  303.       button := Do_Dialog ( Info_Box, 0 ) ;
  304.       End_Dialog ( Info_Box ) ;
  305. END ;
  306.  
  307.  
  308. PROCEDURE Set_Up_Dialog;
  309.  
  310.   BEGIN
  311.     dialog := New_Dialog( 15, 0, 0, 52, 14 ) ;
  312.     dummy := Add_DItem( dialog, G_Box, None, 0, 0, 52, 14, 2, $1121 );
  313.     dummy := Add_DItem( dialog, G_BoxText, None, 6, 1, 40, 2, 1, $1180 );
  314.     Set_DText(dialog, dummy, 'QUICK LABEL PROGRAM' ,System_Font, TE_Center );
  315.     dummy := Add_DItem( dialog, G_BoxText, None, 6, 3, 40, 1, 1, $1180 );
  316.     Set_DText( dialog, dummy, 'by David Lindsley', Small_Font, TE_Center );
  317.     first_item := Add_DItem( dialog, G_FText,Editable, 9, 6, 32, 1, 0, $1180 );
  318.     Set_DEdit( dialog, first_item, '________________________________',
  319.     'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '', System_Font, TE_Center );
  320.     second_item := Add_Ditem(dialog, G_FText, Editable, 9, 7, 32, 1, 0, $1180);
  321.     Set_DEdit( dialog, second_item, '________________________________',
  322.     'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '', System_Font, TE_Center );
  323.     third_item := Add_DItem( dialog, G_FText, Editable, 9, 8, 32, 1, 0, $1180);
  324.     Set_DEdit( dialog, third_item, '________________________________',
  325.     'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '', System_Font, TE_Center );
  326.     fourth_item := Add_DItem(dialog, G_FText, Editable, 9, 9, 32, 1, 0, $1180);
  327.     Set_DEdit( dialog, fourth_item, '________________________________',
  328.         'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX','',System_Font,TE_Center );
  329.     print_btn := Add_DItem( dialog, G_Button, Selectable|Exit_Btn|Default,
  330.                         5, 12, 8, 1, 1, $1180 ) ;
  331.     Set_DText( dialog, print_btn, 'PRINT', System_Font, TE_Center ) ;
  332.     cancel_btn := Add_DItem( dialog, G_Button, Selectable|Exit_Btn,
  333.                         35, 12, 8, 1, 1, $1180 ) ;
  334.     Set_DText( dialog, cancel_btn, 'QUIT', System_Font, TE_Center ) ;
  335.     info_btn := Add_DItem(dialog, G_Button, Selectable|Touch_Exit,
  336.                         15, 12, 8, 1, 1, $1180 );
  337.     Set_DText( dialog, info_btn, 'INFO', System_Font, TE_Center );
  338.     size_btn := Add_DItem(dialog, G_Button, Selectable|Touch_Exit,
  339.                         25, 12, 8, 1, 1, $1180 );
  340.     Set_DText( dialog, size_btn, 'STYLE' , System_Font, TE_Center );
  341.  
  342.  
  343.   END;
  344.  
  345. PROCEDURE LPrint(P:Adrptr);
  346.  
  347.  
  348.   BEGIN
  349.     status := printout_stat;
  350.     if status = 0 then begin
  351.        dummy := do_alert('[3][ | | Turn the printer on.][ OK ]',1);
  352.     end;
  353.     Rewrite(Adrfile,'PRN:' );   { OPEN UP PRINTER }
  354.     Writeln(Adrfile,P^.FirstLine);
  355.     Writeln(Adrfile,P^.SecondLine);
  356.     Writeln(Adrfile,P^.ThirdLine);
  357.     Writeln(Adrfile,P^.Fourthline);
  358.     Writeln(Adrfile);  { blank line }
  359.     Writeln(Adrfile);  { blank line }
  360.   END;
  361.  
  362.  
  363. PROCEDURE Show_Box(P:Adrptr);
  364.   BEGIN
  365.     REPEAT
  366.       Center_Dialog( dialog ) ;
  367.       Obj_SetState(dialog,print_btn,Normal, False );
  368.       Obj_SetState(dialog,info_btn, Normal, False );
  369.       Obj_SetState(dialog,cancel_btn,Normal,False );
  370.       Obj_SetState(dialog,size_btn,Normal,False );
  371.       Set_DText (dialog,first_item,P^.FirstLine,System_Font, TE_Left);
  372.       Set_DText (dialog,second_item,P^.SecondLine,System_Font, TE_Left);
  373.       Set_DText (dialog,third_item,P^.ThirdLine,System_Font, TE_Left);
  374.       Set_DText (dialog,fourth_item,P^.FourthLine,System_Font, TE_Left);
  375.       button := Do_Dialog( dialog, first_item ) ;
  376.       IF (button<>cancel_btn ) THEN
  377.          BEGIN
  378.            Get_DEdit(dialog,first_item,P^.FirstLine);
  379.            Get_DEdit(dialog,second_item,P^.SecondLine);
  380.            Get_DEdit(dialog,third_item, P^.ThirdLine);
  381.            Get_DEdit(dialog,fourth_item,P^.FourthLine);
  382.          END;
  383.        IF button = print_btn THEN
  384.          BEGIN
  385.            LPrint(P)
  386.          END;
  387.        IF button = info_btn THEN
  388.          BEGIN
  389.                   infodialog;
  390.           END;
  391.         IF button = size_btn THEN
  392.           BEGIN
  393.                 styledialog;
  394.           END;
  395.        IF button = cancel_btn THEN
  396.          BEGIN
  397.            b:= do_alert('[1][ | |You pressed the QUIT button][I know|oops]',1);
  398.            IF b = 1 THEN
  399.              BEGIN
  400.                flag := TRUE;
  401.              END;
  402.            END;
  403.     UNTIL (flag = TRUE) OR (P = NIL);
  404.  
  405.        d := do_alert('[2][Return printer to default mode?][ YES | NO ]',1);
  406.     if d = 1 then begin
  407.              Rewrite(Adrfile, 'PRN:');
  408.              Write(Adrfile, chr(27), chr(64));
  409.     end;
  410.   END;
  411.  
  412.  
  413. BEGIN
  414.   IF Init_Gem >= 0 THEN
  415.     BEGIN
  416.       init_mouse;
  417.       res := getrez;
  418.       if res = 0 then
  419.         BEGIN
  420.           dummy:=do_alert('[3][ | | Does not support Low Resolution][ ok ]',1);
  421.           halt;
  422.         END;
  423.       status := printout_stat;
  424.         if status = 0 then begin
  425.           dummy := do_alert('[3][ | | Turn the printer on.][ OK ]',1);
  426.         end;
  427.       Set_Mouse( M_Point_Hand );
  428.       Set_Up_Dialog;
  429.       New(Adrs);
  430.       Adrs^.FirstLine := '';
  431.       Show_Box(Adrs);
  432.      Exit_Gem ;
  433.     END;
  434. END.
  435.